import 'package:ai/page/search/RankItem.dart';
import 'package:ai/util/CommonUtils.dart';
import 'package:auto_route/annotations.dart';
import 'package:flutter/material.dart';

import '../../config/Config.dart';

@RoutePage()
class SearchPage extends StatefulWidget {
  const SearchPage({super.key});

  @override
  State<SearchPage> createState() => _SearchPageState();
}

class _SearchPageState extends State<SearchPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          CommonUtils.getImageAsset("bg_create_title"),
          Scaffold(
            backgroundColor: Colors.transparent,
            appBar: AppBar(
              backgroundColor: Colors.transparent,
              leading: IconButton(
                iconSize: 16,
                padding: const EdgeInsets.all(0),
                onPressed: () {
                  CommonUtils.back(context);
                },
                icon: const Icon(
                  Icons.arrow_back_ios_new_rounded,
                ),
              ),
              title: const Text("内容搜索"),
              centerTitle: true,
              bottom: PreferredSize(
                preferredSize: const Size.fromHeight(50),
                child: Container(
                  height: 48,
                  padding: const EdgeInsets.symmetric(horizontal: 16),
                  child: SearchBar(
                    elevation: WidgetStateProperty.all(0.5),
                    leading: const Icon(Icons.search),
                    hintText: "搜索你想要的功能",
                    trailing: <Widget>[
                      ElevatedButton(
                        style: ButtonStyle(
                          backgroundColor:
                              WidgetStateProperty.all(Config.color69f),
                        ),
                        onPressed: () {},
                        child: const Text(
                          "搜索",
                          style: TextStyle(
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            body: ListView(
              padding: const EdgeInsets.symmetric(horizontal: 24),
              children: const [
                SizedBox(
                  height: 24,
                ),
                Text(
                  "热门搜索词：",
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                  ),
                ),
                SizedBox(
                  height: 16,
                ),
                RankItem(title: "写作", rank: 1),
                SizedBox(
                  height: 16,
                ),
                RankItem(title: "视频", rank: 2),
                SizedBox(
                  height: 16,
                ),
                RankItem(title: "论文", rank: 3),
                SizedBox(
                  height: 16,
                ),
                RankItem(title: "广告", rank: 4),
                SizedBox(
                  height: 16,
                ),
                RankItem(title: "新媒体", rank: 5),
                SizedBox(
                  height: 16,
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
